package cn.lutu.lutu.service.impl;

import cn.lutu.lutu.mapper.SpotMapper;
import cn.lutu.lutu.pojo.dto.SpotDTO;
import cn.lutu.lutu.pojo.entity.Spot;
import cn.lutu.lutu.pojo.vo.SpotVO;
import cn.lutu.lutu.response.ResultVO;
import cn.lutu.lutu.service.SpotService;
import com.sun.corba.se.spi.ior.IdentifiableFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SpotServiceImpl implements SpotService {
    @Autowired
    SpotMapper mapper;

    @Override
    public void insert(SpotDTO spotDTO) {
        Spot spot = new Spot();
        BeanUtils.copyProperties(spotDTO,spot);
        mapper.insert(spot);
    }

    @Override
    public void update(SpotDTO spotDTO) {
        Spot spot = new Spot();
        BeanUtils.copyProperties(spotDTO,spot);
        mapper.update(spot);
    }

    @Override
    public void delete(Long id) {
        mapper.delete(id);
    }

    @Override
    public ResultVO select(Long id) {
        Spot spot = new Spot();
        if (spot.getId()==null){
            return new ResultVO(1011,"失败");
        }
        List<SpotVO> list = mapper.select(id);
        return ResultVO.ok(list);
    }
}
